# -*- mode: org; fill-column: 80; -*-
#+TITLE: GNU Guix Calculate Hashes
#+AUTHOR: Zelphir Kaltstahl
#+EMAIL: zelphirkaltstahl@posteo.de
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO WIP DEPRECATED | DONE
#+DATE: [2021-09-12 Sun]
#+KEYWORDS: Guix GNU hash calculation
#+LANGUAGE: English
#+PRIORITIES: A E E
#+EXCLUDE_TAGS: noexport
#+OPTIONS: ^:{}
#+OPTIONS: H:10
#+OPTIONS: toc:2
#+OPTIONS: tags:nil
#+OPTIONS: tasks:t
#+OPTIONS: H:6
#+OPTIONS: p:nil
#+OPTIONS: pri:nil
#+OPTIONS: prop:nil
#+OPTIONS: todo:t
#+OPTIONS: stat:nil
#+OPTIONS: |:t
#+OPTIONS: inline:nil
#+OPTIONS: date:t


* Calculate project hashsums
:PROPERTIES:
:CUSTOM_ID: calculate-project-hashsums
:END:

GNU Guix makes extensive use of hashsums for verifying integrity of
packages. When creating a package or creating a patch for an existing package,
calculation of the correct hashsum is required.


The correct way to calculate the hash of a package depends on what method is
used to fetch the package. The methods of fetching the package are documented at
[[https://guix.gnu.org/manual/en/html_node/origin-Reference.html]].

** Using git-fetch method
:PROPERTIES:
:custom_id: calculate-project-hashsums-using-git-fetch-method
:END:

If one uses ~(method git-fetch)~ in the package definition, one needs to
calculate the hash of a package using the following command inside the root
directory of the package's source code:

#+begin_src shell
guix hash --exclude-vcs --serializer=nar .
#+end_src

*** TODO Open questions

What format does one need to use?

#+begin_src shell
guix hash --exclude-vcs --serializer=nar --format=??? .
#+end_src

Is the default one correct?

Or does one need to specify =base32=?

** Using url-fetch method
:PROPERTIES:
:custom_id: calculate-project-hashsums-using-url-fetch-method
:END:

If one uses ~(method url-fetch)~ in the package definition, referencing a
release tarball (=tar.gz=), one needs to calculate the hash of a package using
the following command:

#+begin_src shell
guix download <URL OF RELEASE TARBALL>
#+end_src
